<?php

/**
 * This is the model class for table "trazadoras.nino".
 *
 * The followings are the available columns in table 'trazadoras.nino':
 * @property integer $id
 * @property integer $id_beneficiario
 * @property integer $id_prestacion
 * @property integer $id_tipotrazadora
 * @property string $fecha_control
 * @property string $peso
 * @property string $talla
 * @property string $per_cefalico
 * @property string $triple_viral
 * @property string $adolecente
 * @property string $ta_alta
 * @property string $ta_baja
 * @property string $salud_escolar
 * @property string $dep_residencia
 * @property string $fecha_carga
 * @property string $clave_beneficiario
 *
 * The followings are the available model relations:
 * @property TipoTrazadora $id
 */
class Nino extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'trazadoras.nino';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('id_beneficiario, id_prestacion, id_tipotrazadora, fecha_control, peso, talla, adolecente, fecha_carga, clave_beneficiario', 'required'),
			array('id_beneficiario, id_prestacion, id_tipotrazadora', 'numerical', 'integerOnly'=>true),
			array('peso, talla, per_cefalico', 'length', 'max'=>7),
			array('adolecente, salud_escolar', 'length', 'max'=>1),
			array('ta_alta, ta_baja', 'length', 'max'=>5),
			array('triple_viral, dep_residencia', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, id_beneficiario, id_prestacion, id_tipotrazadora, fecha_control, peso, talla, per_cefalico, triple_viral, adolecente, ta_alta, ta_baja, salud_escolar, dep_residencia, fecha_carga, clave_beneficiario', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'id' => array(self::BELONGS_TO, 'TipoTrazadora', 'id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'id_beneficiario' => 'Id Beneficiario',
			'id_prestacion' => 'Id Prestacion',
			'id_tipotrazadora' => 'Id Tipotrazadora',
			'fecha_control' => 'Fecha Control',
			'peso' => 'Peso',
			'talla' => 'Talla',
			'per_cefalico' => 'Per Cefalico',
			'triple_viral' => 'Triple Viral',
			'adolecente' => 'Adolecente',
			'ta_alta' => 'Ta Alta',
			'ta_baja' => 'Ta Baja',
			'salud_escolar' => 'Salud Escolar',
			'dep_residencia' => 'Dep Residencia',
			'fecha_carga' => 'Fecha Carga',
			'clave_beneficiario' => 'Clave Beneficiario',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('id_beneficiario',$this->id_beneficiario);
		$criteria->compare('id_prestacion',$this->id_prestacion);
		$criteria->compare('id_tipotrazadora',$this->id_tipotrazadora);
		$criteria->compare('fecha_control',$this->fecha_control,true);
		$criteria->compare('peso',$this->peso,true);
		$criteria->compare('talla',$this->talla,true);
		$criteria->compare('per_cefalico',$this->per_cefalico,true);
		$criteria->compare('triple_viral',$this->triple_viral,true);
		$criteria->compare('adolecente',$this->adolecente,true);
		$criteria->compare('ta_alta',$this->ta_alta,true);
		$criteria->compare('ta_baja',$this->ta_baja,true);
		$criteria->compare('salud_escolar',$this->salud_escolar,true);
		$criteria->compare('dep_residencia',$this->dep_residencia,true);
		$criteria->compare('fecha_carga',$this->fecha_carga,true);
		$criteria->compare('clave_beneficiario',$this->clave_beneficiario,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Nino the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
